#include "dockwindow.h"
#include <QTextEdit>
#include <QDockWidget>

DockWindow::DockWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowTitle(tr("DockWindows"));  //设置标题文字
    QTextEdit *te = new QTextEdit(this);  //QTextEdit为主窗口
    te ->setText(tr("Main Windows"));
    te ->setAlignment(Qt::AlignCenter);
    setCentralWidget(te);  //设为主窗口的中央窗口
    //停靠窗口1
    QDockWidget *dock = new QDockWidget(tr("DockWindow1"),this);
    //可移动
    dock->setFeatures(QDockWidget::DockWidgetMovable); //a
    dock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
    QTextEdit *te1 = new QTextEdit();
    te1->setText(tr("Window1,The dock widget can be moved between docks by the user''"));
    dock ->setWidget(te1);
    addDockWidget(Qt::TopDockWidgetArea,dock);

    //停靠窗口2
    dock = new QDockWidget(tr("DockWindows2"),this);
    dock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable);
    QTextEdit *te2 = new QTextEdit();
    te2 ->setText(tr("Window2,The dock widget can be detached from the main window,""and floated as an independent window,and can be closed"));
    dock->setWidget(te2);
    addDockWidget(Qt::RightDockWidgetArea,dock);

    //停靠窗口3
    dock = new QDockWidget(tr("DockWindow3"),this);
    dock-> setFeatures(QDockWidget::AllDockWidgetFeatures); //全部特性
    QTextEdit *te3 = new QTextEdit();
    te3 -> setText(tr("Window3,The dock widget can ben closed,moved,and floated"));
    dock -> setWidget(te3);
    addDockWidget(Qt::RightDockWidgetArea,dock);
}

DockWindow::~DockWindow()
{

}
